/** 文本输入框 */

import { Input } from 'antd';
import React from 'react';

export interface IPropertyInputProps {
    value: string;
    onChange: (e: string) => void;
}

export default function PropertyInput(props: IPropertyInputProps) {

    const [value, setValue] = React.useState(props.value);

    React.useEffect(() => { setValue(props.value) }, [props.value])

    return (
        <Input
            size="small"
            value={value}
            onBlur={e => { props.onChange(value) }}
            onChange={e => { setValue(e.target.value) }}
            onPressEnter={() => { props.onChange(value) }}
        />
    )
}